package com.zjl.redis.第06章_SpringBoot整合redis;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * ClassName: swagger2
 * Package: com.zjl.redis.第06章_SpringBoot整合redis
 * Description: 由于 springBoot 3.xx版本太高，不能使用Swagger2，所以不使用
 * spring boot3.x版本依赖于jakarta依赖包，但是swagger依赖底层应用的javax依赖包，所以只要一启动就会报错。
 *
 * @Author 张蛟龙
 * @Create 2024/6/30 21:59
 * @Version 1.0
 *
 */
//@Configuration
//@EnableSwagger2
public class D_SwaggerConfig {
    @Value("${spring.swagger2.enabled}")
    private Boolean enabled;
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .enable(enabled)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zjl.redis.第06章_SpringBoot整合redis"))
                .paths(PathSelectors.any())
                .build();
    }

    public ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("接口文档" + "\t" +
                        DateTimeFormatter.ofPattern("yyyy-MM-dd")
                                .format(LocalDateTime.now()))
                .description("SpringBoot整合redis,有问题给xxx邮件:839864826@qq.com")
                .version("1.0")
                .termsOfServiceUrl("https://www.baidu.com/")
                .build();
    }
}
